package demo12;

public class SyncDemo1 {
    void getClassObject(){
        // this.getClass() == SyncDemo1.class
    }

    public synchronized void method(){

    }
    public void method2(){
        synchronized (this){

        }
    }

    public static synchronized void staticMethod(){

    }
    public static void staticMethod2(){
        synchronized (SyncDemo1.class){

        }
    }

    public void sonMethod(){
        // 同步代码块，用在方法内部
        Object o = new Object();
        synchronized (o){
            // o 这个引用不能是null

        }
    }
}
